package org.bookie.core.services;

import javax.mail.MessagingException;

import org.bookie.model.User;

/**
 * Service for encapsulation of the user related actions
 * 
 * @author zubairov
 *
 */
public interface IUserManager {

	public static enum RegistrationResult {
		
		OK(0), DUPLICATE_EMAIL(1), DUPLICATE_USERNAME(2);

		private final int value;
		
		private RegistrationResult(int value) {
			this.value = value;
		}

	    public int value() {
	        return value;
	    }

		public String toString() {
			return String.valueOf(value);
		}
	}
	
	/**
	 * Register new user
	 * @param user user to be registered
	 * @param sendEmail wherever send email or not, if email is not send then user is activated immediately
	 * @return RegistrationResult
	 * @throws MessagingException 
	 */
	public RegistrationResult registerNewUser(User user, boolean sendEmail) throws MessagingException;

	
	/**
	 * This method recreates user password and send it to user via email
	 * 
	 * @return true if user with given username and email exists and password reset was ok
	 * @param username
	 * @param email
	 * @throws MessagingException 
	 */
	public boolean recreatePassword(String username, String email) throws MessagingException;


	/**
	 * Old method to register user, send email by default
	 * @param capture
	 * @return
	 * @throws MessagingException 
	 */
	public RegistrationResult registerNewUser(User capture) throws MessagingException;
	
}
